package com.wantup.listener;

import org.apache.tomcat.util.net.ApplicationBufferHandler;
import org.springframework.context.ApplicationListener;
import org.springframework.messaging.simp.stomp.StompHeaderAccessor;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.messaging.SessionSubscribeEvent;
import org.springframework.web.socket.messaging.StompSubProtocolHandler;
import sun.plugin2.message.StopAppletAckMessage;

/**
 * @ClassName SubscribeEventListener
 * @Description websocket 订阅事件监听器
 * @Author zhaoluowei
 * @Date 2019/6/23  19:38
 * @Version 1.0
 */

@Component
public class SubscribeEventListener implements ApplicationListener<SessionSubscribeEvent> {


    @Override
    public void onApplicationEvent(SessionSubscribeEvent sessionSubscribeEvent) {
        StompHeaderAccessor accessor = StompHeaderAccessor.wrap(sessionSubscribeEvent.getMessage());

        System.out.println("获取消息类型  "+accessor.getCommand().getMessageType());
        System.out.println("session标识符  "+accessor.getSessionId());
        System.out.println("定约的id 标识  "+accessor.getSubscriptionId());
        System.out.println("目的地  "+accessor.getDestination());

    }
}
